﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:OMANE_Modules_TauxGarantis_ViewModels="clr-namespace:OMANE.Modules.TauxGarantis.ViewModels"
    xmlns:txgar="clr-namespace:OMANE.Modules.TauxGarantis"
	mc:Ignorable="d"
	x:Class="Views.ViewCalculsDetailles"
	x:Name="UserControl"
	d:DesignWidth="924" d:DesignHeight="480">


    <!--<UserControl.DataContext>
        <Binding Source="{x:Static OMANE_Modules_TauxGarantis_ViewModels:Locator.ViewModelResScenCentralMeth1CalculsDetStatic}" />
    </UserControl.DataContext>-->
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <txgar:DataRowViewConverter x:Key="DataRowViewConverterSource" Relation="SourceToLink" />
        <txgar:DataRowViewConverter x:Key="DataRowViewConverterGroup" Relation="GroupToLink" />
    </UserControl.Resources>

    <UserControl.DataContext>
        <OMANE_Modules_TauxGarantis_ViewModels:ViewModelCalculsDetailles/>
    </UserControl.DataContext>
    <Grid >
    	 <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>                
                <RowDefinition  />
            </Grid.RowDefinitions>
			<CheckBox Visibility="Collapsed" IsChecked="False"  Content="Cliquez ici pour choisir le mode d'édition" FontWeight="Bold" Margin="5,5,0,5" Name="modeCheckBox" />
        <Grid Name="detailGrd" Grid.Row="1" d:IsHidden="True" Visibility="Collapsed">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Name="OriginalRow"/>
                <RowDefinition Height="5"/>
                <RowDefinition Name="GroupRow" />
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <RadioButton Content="Afficher Tout" Margin="5" GroupName="TableGroup" IsChecked="True" Name="ShowAll" />
                <RadioButton Content="Afficher les lignes du groupe" Margin="5" GroupName="TableGroup" Name="ShowSelected" />
                <RadioButton Content="Afficher les lignes qui ne sont pas du groupe" Margin="5" GroupName="TableGroup" Name="ShowUnselected" />
                <RadioButton Content="Afficher les lignes selectionnées" Margin="5" GroupName="TableGroup" Name="ShowSelectedOne" />
                <RadioButton Content="Afficher les non-selectionnés" Margin="5" GroupName="TableGroup" Name="ShowNeverSelected" />
            </StackPanel>
            <Expander Name="OriginalExpander"  Grid.Row="1" Collapsed="OriginalExpander_Collapsed" Expanded="OriginalExpander_Expanded">
                <Expander.Header>
                    <StackPanel Orientation="Horizontal" Margin="2"  >
                        <TextBlock Margin="5,0,0,0" Text="Table Originelle" HorizontalAlignment="Left" VerticalAlignment="Center"  />
                        <ComboBox HorizontalAlignment="Left" Margin="50,0,0,0" MinWidth="150" VerticalAlignment="Center" ItemsSource="{Binding Columns, ElementName=OriginalGrd}" Style="{DynamicResource OMANE_cbx}" IsTabStop="False" Text="Colonnes Affichées" SelectedIndex="0" IsTextSearchEnabled="False" >
                            <ComboBox.ItemContainerStyle>
                                <Style TargetType="ComboBoxItem">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ComboBoxItem">
                                                <CheckBox Content="{Binding Path=Header}" Padding="5,1,1,1" VerticalContentAlignment="Center" VerticalAlignment="Center" Margin="0,1" FontWeight="Bold" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" IsChecked="True" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ComboBox.ItemContainerStyle>
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="Colonnes Affichées" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <TextBlock Text="Filtre" Margin="50,0,0,0" VerticalAlignment="Center" />
                        <CheckBox HorizontalAlignment="Left"   Margin="5,0,0,0" VerticalAlignment="Center" HorizontalContentAlignment="Stretch" Name="FilterCheckBox" IsThreeState="False" />
                        <TextBox TextChanged="FilterTextBox_TextChanged" PreviewKeyUp="FilterTextBox_PreviewKeyUp" FontWeight="Bold" Name="FilterTextBox" HorizontalAlignment="Left" MinWidth="150" IsEnabled="{Binding ElementName=FilterCheckBox, Path=IsChecked}" AutoWordSelection="True" AllowDrop="False" IsTabStop="False"  />
                        <Button Content="Ajouter une colonne calculée" Margin="50,0,0,0" Style="{StaticResource btnBase_OMANE}" Name="BtnComputedColumn" />
                    </StackPanel>
                </Expander.Header>
                <Grid Background="#FFE5E5E5">
                    <DataGrid ItemsSource="{Binding OriginalTable}" ItemStringFormat="%" Name="OriginalGrd" IsSynchronizedWithCurrentItem="True" ColumnHeaderHeight="25" CanUserDeleteRows="False" CanUserAddRows="False" >
                        <DataGrid.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Grouper" Click="MenuItem1_Click_1" />
                            </ContextMenu>
                        </DataGrid.ContextMenu>
                        <DataGrid.ColumnHeaderStyle>
                            <Style TargetType="DataGridColumnHeader">
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="DataGridColumnHeader">
                                            <Grid Background="{DynamicResource DegradeBckFenetre}">
                                                <ContentPresenter ContentSource="Content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                                <Thumb x:Name="PART_LeftHeaderGripper" 
											HorizontalAlignment="Left"
											Width="8" 
											Cursor="ScrollWE"
											Background="Transparent">
                                                    <Thumb.Template>
                                                        <ControlTemplate TargetType="{x:Type Thumb}">
                                                            <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
                                                        </ControlTemplate>
                                                    </Thumb.Template>
                                                </Thumb>
                                                <Thumb x:Name="PART_RightHeaderGripper" 
											HorizontalAlignment="Right"
											Width="8" 
											Cursor="ScrollWE"
											Background="Transparent" >
                                                    <Thumb.Template>
                                                        <ControlTemplate TargetType="{x:Type Thumb}">
                                                            <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
                                                        </ControlTemplate>
                                                    </Thumb.Template>
                                                </Thumb>

                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </DataGrid.ColumnHeaderStyle>
                    </DataGrid>
                </Grid>
            </Expander>
            <GridSplitter HorizontalAlignment="Stretch" Grid.Row="2"/>
            <Expander Name="GroupExpander"  d:LayoutOverrides="Height" Grid.Row="3" Collapsed="GroupExpander_Collapsed" Expanded="GroupExpander_Expanded">
                <Expander.Header>
                    <StackPanel Orientation="Horizontal" Margin="2"  >
                        <TextBlock Margin="5,0,0,0" Text="Table des Groupes" HorizontalAlignment="Left" VerticalAlignment="Center"  />
                        <ComboBox HorizontalAlignment="Left" Margin="50,0,0,0" MinWidth="150" VerticalAlignment="Center" ItemsSource="{Binding Columns, ElementName=GroupGrd}" Style="{DynamicResource OMANE_cbx}" >
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Content="{Binding Path=Header}" Padding="5,1,1,1" VerticalContentAlignment="Center" VerticalAlignment="Center" Margin="0,1" FontWeight="Bold" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" IsChecked="True" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <ComboBox Visibility="Collapsed"  HorizontalAlignment="Left" Margin="50,0,0,0" MinWidth="150" VerticalAlignment="Center" ItemsSource="{Binding Columns, ElementName=GroupGrd}" Style="{DynamicResource OMANE_cbx}" DisplayMemberPath="Header" SelectedItem="{Binding Source={StaticResource DataRowViewConverterGroup}, Path=Column, Mode=OneWayToSource}" />
                        <ComboBox Visibility="Collapsed"  HorizontalAlignment="Left" Margin="50,0,0,0" MinWidth="150" VerticalAlignment="Center" ItemsSource="{Binding Columns, ElementName=OriginalGrd}" Style="{DynamicResource OMANE_cbx}" DisplayMemberPath="Header" SelectedItem="{Binding Source={StaticResource DataRowViewConverterSource}, Path=Column, Mode=OneWayToSource}" />
                    </StackPanel>
                </Expander.Header>
                <Grid Background="#FFE5E5E5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="5"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <DataGrid ItemsSource="{Binding GroupTable}" ItemStringFormat="%" Name="GroupGrd" SelectionChanged="GroupGrd_SelectionChanged" SelectionMode="Single" CanUserAddRows="False" CanUserDeleteRows="False" IsSynchronizedWithCurrentItem="True">
                        <DataGrid.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Degrouper" Click="MenuItem1_Click_2" />
                            </ContextMenu>
                        </DataGrid.ContextMenu>
                    </DataGrid>
                    <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
                    <DataGrid Grid.Column="2" ItemsSource="{Binding LinkTable}" IsSynchronizedWithCurrentItem="True" CanUserAddRows="False" CanUserDeleteRows="False" Name="LinkGrd" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn IsReadOnly="True" Header="Group" Binding="{Binding Converter={StaticResource DataRowViewConverterGroup}, ConverterParameter=GroupID}"/>
                            <DataGridTextColumn IsReadOnly="True" Header="Source" Binding="{Binding Converter={StaticResource DataRowViewConverterSource}, ConverterParameter=SourceID}"/>
                            <DataGridTextColumn Header="SpecificWeight" Binding="{Binding Path=SpecificWeight}"/>
                        </DataGrid.Columns>
                        <DataGrid.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Supprimer" Name="MenuItem1" />
                                <!--<MenuItem Header="Selectioner les groupes"  />
                            <MenuItem Header="Selectioner les lignes originales"  />-->
                            </ContextMenu>
                        </DataGrid.ContextMenu>
                    </DataGrid>
                </Grid>
            </Expander>
        </Grid>
        <Grid Name="simpleGrd" Grid.Row="1">
        	<Grid.RowDefinitions>
        		<RowDefinition Height="Auto"/>
        		<RowDefinition />
        	</Grid.RowDefinitions>
			<StackPanel Orientation="Horizontal">
				 <TextBlock Text="Colonnes Affichées" Margin="50,0,0,0" VerticalAlignment="Center" Visibility="Collapsed" />
				 <ComboBox HorizontalAlignment="Left" Margin="5" MinWidth="150" VerticalAlignment="Center" ItemsSource="{Binding Columns, ElementName=simpleDataGrid, Mode=OneWay}" Style="{DynamicResource OMANE_cbx}" IsTabStop="False" Text="Colonnes Affichées" SelectedIndex="0" IsTextSearchEnabled="False" Visibility="Collapsed" >
                            <ComboBox.ItemContainerStyle>
                                <Style TargetType="{x:Type ComboBoxItem}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                                                <CheckBox Content="{Binding Header, Mode=OneWay}" Padding="5,1,1,1" VerticalContentAlignment="Center" VerticalAlignment="Center" Margin="0,1" FontWeight="Bold" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" IsChecked="True" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ComboBox.ItemContainerStyle>
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="Colonnes Affichées" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
						<TextBlock Text="Filtre" Margin="50,0,0,0" VerticalAlignment="Center" Visibility="Collapsed" />
                        <CheckBox HorizontalAlignment="Left"   Margin="5,0,0,0" VerticalAlignment="Center" HorizontalContentAlignment="Stretch" x:Name="simpleFilterCheckBox" IsThreeState="False" Visibility="Collapsed" />
                        <TextBox FontWeight="Bold" x:Name="simpleFilterTextBox" HorizontalAlignment="Left" MinWidth="150" IsEnabled="{Binding IsChecked, ElementName=simpleFilterCheckBox, Mode=OneWay}" AutoWordSelection="True" AllowDrop="False" IsTabStop="False" Visibility="Collapsed"  />
                        <Button Content=". . ."  Style="{StaticResource btnBase_OMANE}" x:Name="simpleBtnFilter" Width="25" Height="25" VerticalAlignment="Center" Margin="5,0,0,0" IsEnabled="{Binding IsChecked, ElementName=simpleFilterCheckBox, Mode=OneWay}" Visibility="Collapsed" />
					    <Button Content="Ajouter une colonne calculée" Margin="50,0,0,0" Style="{StaticResource btnBase_OMANE}" x:Name="simpleBtnComputedColumn" Width="Auto" Visibility="Collapsed" />
		                <Button Content="Options Avancees"  Margin="50,5,0,5" Style="{StaticResource btnBase_OMANE}" Name="AdvancedOptions" Width="150" />
			            <Button Content="Cacher toutes les colonnes"  Margin="50,5,0,5" Style="{StaticResource btnBase_OMANE}" Name="HideShowAll" Width="166" />
			
			</StackPanel>
		    
            <DataGrid xml:lang="fr-FR" ItemsSource="{Binding FinalTable}" Name="simpleDataGrid" CanUserAddRows="False" CanUserDeleteRows="False" Grid.RowSpan="2" Grid.Row="1" AlternatingRowBackground="#FFC4C4C4" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" IsReadOnly="True" Focusable="False" AlternationCount="1" ClipboardCopyMode="IncludeHeader" ColumnHeaderStyle="{DynamicResource DataGridColumnHeaderStyle}">
            	<DataGrid.Resources>
            		<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
            			<Setter Property="HorizontalContentAlignment" Value="Right"/>
            			<Setter Property="VerticalContentAlignment" Value="Center"/>
            			<Setter Property="HorizontalAlignment" Value="Right"/>
            			<Setter Property="VerticalAlignment" Value="Center"/>
            			<Setter Property="IsTabStop" Value="False"/>
            			<Setter Property="Focusable" Value="False"/>
            		</Style>
            		<Style x:Key="DataGridColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}">
            			<Setter Property="ContextMenu">
            				<Setter.Value>
            					<ContextMenu>
            						<MenuItem Header="Cacher"/>
            						<MenuItem Header="Format"/>
            						<MenuItem Header="Filtre"/>
            					</ContextMenu>
            				</Setter.Value>
            			</Setter>
            		</Style>
            	</DataGrid.Resources>
            	
            	<DataGrid.ContextMenu>
            		<ContextMenu>
            			<MenuItem Header="Grouper" Click="SimpleGrd_Grouper_Click"/>
            			<MenuItem Header="Degrouper" Click="SimpleGrd_DeGrouper_Click"/>
            		</ContextMenu>
            	</DataGrid.ContextMenu>
				
            </DataGrid>
        </Grid>
    </Grid>
</UserControl>